﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace BOLL_WPF.Converter
{
    [ValueConversion(typeof(bool), typeof(bool))]
    public class InverseBoolConverter : System.Windows.Data.IValueConverter
    {
        //当值从绑定源传播给绑定目标时，调用方法Convert
        public object Convert(object value, Type targetType, object paramter,
            System.Globalization.CultureInfo culture)
        {
            if(targetType != typeof(bool))
            {
                throw new InvalidOperationException("The target must be a boolean");
                
            }
            return !(bool)value;
        }

        //当值从绑定目标传播给绑定源时，调用此方法ConvertBack
        public object ConvertBack(object value, Type targetType, object parameter,
            System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }
}
